From 97e1a057000511abe8ed85adee6c6474398a427c Mon Sep 17 00:00:00 2001
From: wwd <ericrock@foxmail.com>
Date: Fri, 18 Nov 2016 17:46:25 +0800
Subject: [PATCH] eth: support 1000M ethernet

diff --git a/drivers/net/ethernet/sunxi/eth/sunxi_geth.c b/drivers/net/ethernet/sunxi/eth/sunxi_geth.c
--- a/drivers/net/ethernet/sunxi/eth/sunxi_geth.c
+++ b/drivers/net/ethernet/sunxi/eth/sunxi_geth.c
@@ -265,8 +265,10 @@ static void desc_print(struct dma_desc *desc, int size)
 static int geth_power_on(struct geth_priv *priv)
 {
 	int value;
-	if (gpio_is_valid(priv->gpio_power_hd))
+	if (gpio_is_valid(priv->gpio_power_hd)) {
 		gpio_set_value(priv->gpio_power_hd, 1);
+		mdelay(50);
+		}
 #ifdef CONFIG_GETH_PHY_POWER
 	struct regulator **regu;
 	int ret = 0, i = 0;
@@ -330,8 +332,10 @@ err:
 static void geth_power_off(struct geth_priv *priv)
 {
 	int value;
-	if (gpio_is_valid(priv->gpio_power_hd))
+	if (gpio_is_valid(priv->gpio_power_hd)) {
 		gpio_set_value(priv->gpio_power_hd, 0);
+		mdelay(50);
+		}
 #ifdef CONFIG_GETH_PHY_POWER
 	struct regulator **regu = priv->power;
 	int i = 0;
@@ -1690,6 +1699,10 @@ static int geth_sys_request(struct platform_device *pdev)
 	int ret = 0;
 	struct resource *res;

+	script_item_value_type_e  type;
+	script_item_u item;
+	int req_status;
+
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "geth_extclk");
 	if (unlikely(!res)){
 		ret = -ENODEV;
@@ -1763,6 +1776,20 @@ static int geth_sys_request(struct platform_device *pdev)
 		}
 	}
 #endif
+
+	type = script_get_item("gmac_phy_power", "gmac_phy_power_en", &item);
+	if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
+		priv->gpio_power_hd = -1;
+	} else {
+		/*request gpio*/
+		req_status = gpio_request(item.gpio.gpio, NULL);
+		if (0 != req_status) {
+			pr_err("request gpio failed!\n");
+		}
+		gpio_direction_output(item.gpio.gpio, 1);
+		priv->gpio_power_hd = item.gpio.gpio;
+ 	}
+
 	return 0;

 pin_err: